home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 2
/
Atari Mega Archive CD - Volume 2.iso
/
minix
/
up1510b.tgz
/
up1510b
/
src
/
commands
/
kermit
/
ckudia.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-07-19
|
27KB
|
912 lines
char *dialv = "Dial Command, V2.0(009) 24 Jan 88";
/* C K U D I A -- Dialing program for connection to remote system */
/*
Author: Herm Fischer (HFISCHER@USC-ECLB)
Contributed to Columbia University for inclusion in C-Kermit.
Copyright (C) 1985, Herman Fischer, 16400 Ventura Blvd, Encino CA 91436
Permission is granted to any individual or institution to use, copy, or
redistribute this software so long as it is not sold for profit, provided this
copyright notice is retained.
------
This module should work under all versions of Unix. It calls externally
defined system-depended functions for i/o, but depends upon the existence
of various modem control functions.
This module, and the supporting routines in the ckutio.c module, assume
that the computer and modem properly utilize the following data communi-
cations signals (that means one should prepare the modem to use, not
circumvent, these signals):
Data Terminal Ready: This signal is asserted by the computer
when Kermit is about to ask the modem to dial a call, and is
removed when Kermit wishes to have the modem hang up a call.
The signal is asserted both while Kermit is asking the modem
to dial a specific number, and after connection, while Kermit
is in a data exchange mode.
Carrier detect: This signal must be asserted by the modem when
a carrier is detected from a remote modem on a communications
circuit. It must be removed by the modem when the circuit
disconnects or is hung up. (Carrier detect is ignored while
Kermit is asking the modem to dial the call, because there is
no consistant usage of this signal during the dialing phase
among different modem manufacturers.)
*/
/*
* Modifications:
*
* 21-Jul-85 Fixed failure returns hanging on no carrier signal
* Requires tthang change too (ckutio.c revision)
* -- Herm Fischer
*
* 28-Jun-85 Fixed bug with defaulting the modem-failure message
* in lbuf.
* -- Dan Schullman
*
* 27-Jun-85 Merged in code from Joe Orost at Berkeley for
* supporting the US Robotics modem, which included
* changing the single characters in MDMINF into
* multi-character strings and modifying waitFor.
* -- Dan Schullman
*
* 26-Jun-85 Allow interrupts to be used to abort dialing,
* and ring the bell when a connection is made.
* Reorganized some of the failure paths to use the
* same code, and now close the line on failures.
* Allow use of stored numbers with the DF100 and
* DF200 modems. Handlers now declared after the
* call to setjmp.
* -- Dan Schullman
*
* 24-May-85 DF03, DF100-series, DF200-series, and "unknown" modem
* support added. Also restructured the various data
* tables, fixed some bugs related to missing data and
* missing case labels, and modified the failure message
* to display the "reason" given by the modem.
* -- Dan Schullman
* 16-Mar-87 Support for the ATT7300 UNIX PC internal modem was
* added.
* -- Richard E. Hill
*/
/*
* To add support for another modem, do the following:
*
* Define a modem number symbol (n_XXX) for it, keeping the list
* in alphabetical and numerical order, and renumbering the values
* as necessary.
*
* Create a MDMINF structure for it, again keeping the list alphabetical
* for sanity's sake.
*
* Add the address of the MDMINF structure to the ptrtab array, again
* in alphabetical and numerical order.
*
* Add the "user visible" modem name and corresponding modem number to
* the mdmtab array, again in alphabetical order.
*
* Read through the code and add modem-specific sections as necessary.
*/
/*
* The intent of the "unknown" modem is hopefully to allow KERMIT to support
* unknown modems by having the user type the entire autodial sequence
* (possibly including control characters, etc.) as the "phone number".
* The only reason that the CONNECT command cannot be used to do this is
* that a remote line cannot normally be opened unless carrier is present.
*
* The protocol and other characteristics of this modem are unknown, with
* some "reasonable" values being chosen for some of them. The only way to
* detect if a connection is made is to look for carrier present.
*
* SUPPORT IS CURRENTLY ONLY PARTIALLY SKETCHED OUT FOR THIS. ALSO, IT
* SHOULD PERHAPS BE HANDLED MUCH EARLIER, SIMPLY READING USER INPUT AND
* SENDING IT TO THE MODEM AND ECHOING MODEM RESPONSES BACK TO THE USER,
* ALL THE TIME LOOKING FOR CARRIER. OF COURSE, THE PROBLEM THEN BECOMES
* ONE OF ALLOWING THE USER TO ABORT THE DIALING. WE COULD CHOOSE SOME
* PHRASE THAT WOULD PRESUMABLY NEVER BE A PART OF A VALID AUTODIAL SEQUENCE
* (E.G., "QUIT" and "quit"). -- DS
*/
#include "ckcdeb.h"
#include <stdio.h>
#include <ctype.h>
#include <signal.h>
#include "ckcker.h"
#include "ckucmd.h"
#ifndef ZILOG
#include <setjmp.h> /* Longjumps */
#else
#include <setret.h>
#endif
extern int flow, local, mdmtyp, quiet, speed, parity, seslog;
extern char ttname[], sesfil[];
#ifndef MINIX
#define MDMINF struct mdminf
MDMINF /* structure for modem-specific information */
{
int dial_time; /* time modem allows for dialing (secs) */
char *pause_chars; /* character(s) to tell modem to pause */
int pause_time; /* time associated with pause chars (secs) */
char *wake_str; /* string to wakeup modem & put in cmd mode */
int wake_rate; /* delay between wake_str characters (msecs) */
char *wake_prompt; /* string prompt after wake_str */
char *dmode_str; /* string to put modem in dialing mode */
char *dmode_prompt; /* string prompt for dialing mode */
char *dial_str; /* dialing string, with "%s" for number */
int dial_rate; /* delay between dialing characters (msecs) */
};
/*
* Define symbolic modem numbers.
*
* The numbers MUST correspond to the ordering of entries
* within the ptrtab array, and start at one (1).
*
* It is assumed that there are relatively few of these
* values, and that the high(er) bytes of the value may
* be used for modem-specific mode information.
*
* REMEMBER that only the first eight characters of these
* names are guaranteed to be unique.
*/
#define n_CERMETEK 1
#define n_DF03 2
#define n_DF100 3
#define n_DF200 4
#define n_GDC 5
#define n_HAYES 6
#define n_PENRIL 7
#define n_RACAL 8
#define n_UNKNOWN 9
#define n_USROBOT 10
#define n_VENTEL 11
#define n_CONCORD 12
#define n_ATT7300 13 /* added for PC7300 */
/*
* Declare modem "variant" numbers for any of the above for which it is
* necessary to note various operational modes, using the second byte
* of a modem number.
*
* It is assumed that such modem modes share the same modem-specific
* information (see MDMINF structure) but may differ in some of the actions
* that are performed.
*/
#define n_HAYESNV ( n_HAYES + ( 1<<8 ) )
/*
* Declare structures containing modem-specific information.
*
* REMEMBER that only the first SEVEN characters of these
* names are guaranteed to be unique.
*/
static
MDMINF CERMETEK = /* information for "Cermetek Info-Mate 212 A" modem */
{
20, /* dial_time */
"BbPpTt", /* pause_chars */
0, /* pause_time */ /** unknown -- DS **/
" XY\016R\r", /* wake_str */
200, /* wake_rate */
"", /* wake_prompt */
"", /* dmode_str */
"", /* dmode_prompt */
"\016D '%s'\r", /* dial_str */
200 /* dial_rate */
};
static
MDMINF DF03 = /* information for "DEC DF03-AC" modem */
{
27, /* dial_time */
"=", /* pause_chars */ /* wait for second dial tone */
15, /* pause_time */
"\001\002", /* wake_str */
0, /* wake_rate */
"", /* wake_prompt */
"", /* dmode_str */
"", /* dmode_prompt */
"%s", /* dial_str */
0 /* dial_rate */
};
static
MDMINF DF100 = /* information for "DEC DF100-series" modem */
/*
* The telephone "number" can include "P"s and/or "T"s
* within it to indicate that subsequent digits are
* to be dialed using pulse or tone dialing. The
* modem defaults to pulse dialing. You may modify
* the d